const Net = require('../../common.js');
Page({
  data: {
    title: ''
  },
  onLoad: function (options) {
    var _this = this
    _this.setData({
      id: options.id,
      title: options.title
    })
    _this.onPageInfo(options.id)
  },
  onReady: function () {},
  onShow: function () {},
  onHide: function () {},
  onUnload: function () {},
  onPullDownRefresh: function () {},
  onReachBottom: function () {},
  onShareAppMessage: function () {},
  onPageInfo(e) {
    var _this = this
    Net.link('v1/mallOrder/' + e, {
        id: e
      },
      function (res) {
        console.log(res)
        res.data.data.pay_time = Net.formatTime(res.data.data.create_time, 'Y-M-D h:m:s')
        if (res.data.data.mall_order_queue) {
          res.data.data.mall_logistics.logistics_time = Net.formatTime(res.data.data.mall_logistics.logistics_time, 'Y-M-D h:m:s')
          res.data.data.mall_order_queue.expire_time = Net.formatTime(res.data.data.mall_order_queue.expire_time, 'Y-M-D h:m:s')
        }
        _this.setData({
          info: res.data.data
        })
      }, "GET")
  },
  onUserCallPhone(e) {
    wx.makePhoneCall({
      phoneNumber: e.currentTarget.id,
    })
  },
  onCopy(e) {
    wx.setClipboardData({
      data: e.currentTarget.id,
      success(res) {
        wx.getClipboardData({})
      }
    })
  },
  onExeeico() {
    Net.PageRoter('_address', '?id=' + Net.data('id'), 'nav')
  },
  onToDeliverGoods(e) {
    if (e.currentTarget.id == 1) {
      Net.PageRoter('_onToDeliverGoods', '?order_num=' + Net.data('id'), 'nav')
    } else if (e.currentTarget.id == 2) {
      Net.PageRoter('_address', '?id=' + Net.data('id'), 'nav')
    }
  },
})